package com.ktjy.controller;

import cn.max.anno.RequestMapping;
import com.ktjy.entity.Auction;
import com.ktjy.mapper.AuctionMapper;
import com.ktjy.service.AuctionService;
import com.ktjy.service.Impl.AuctionServiceImpl;
import com.ktjy.util.MyBatisUtil;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

public class AuctionControll {
    @RequestMapping("/getAuction")
    public String getAuction(HttpServletRequest request, HttpServletResponse response) {
        //通过MyBatisUtil创建SqlSession
        AuctionService auctionService = new AuctionServiceImpl();
        List<Auction> auctionList = auctionService.getAuctionList();
        request.setAttribute("auctionList", auctionList);
        String userIsAdmin = (String) request.getSession().getAttribute("userIsAdmin");
        if (userIsAdmin.equals("1")) {
            //登录成功，跳转到管理员页面
            return "forward:/auctionDetail.jsp";
        } else {
            //登录成功，跳转到用户页面
            return "forward:/auctionList.jsp";
        }
    }
}
